<template>
  <div>
    <header class="header">
      <comp-header>
        <template v-slot:ctitle>首页</template>
        <template v-slot:cicon
          ><span class="fa fa-align-justify"></span
        ></template>
      </comp-header>
    </header>
    <div class="box">
      <div class="pay-box">
        <div class="top">
          <ul>
            <li>
              <a href="#/payma">
                <span class="icon"></span>
                <span class="text">付款码</span>
              </a>
            </li>
            <li>
              <a href="#/saoma">
                <span class="icon"></span>
                <span class="text">扫码</span>
              </a>
            </li>
            <li>
              <a href="javascript:;">
                <span class="icon"></span>
                <span class="text">银行卡</span>
              </a>
            </li>
            <li>
              <a href="#/shouma">
                <span class="icon"></span>
                <span class="text">收款码</span>
              </a>
            </li>
          </ul>
        </div>
        <div class="bottom">
          <ul>
            <li>
              <a href="javascript:;">
                <span class="text">乘车码</span>
              </a>
            </li>
            <li>
              <a href="javascript:;">
                <span class="text">领券</span>
              </a>
            </li>
            <li>
              <a href="javascript:;">
                <span class="text">优惠券</span>
              </a>
            </li>
            <li>
              <a href="javascript:;">
                <span class="text">附近</span>
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="types">
      <ul>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">金融理财</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">商业保险</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">信用借款</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">火车机票</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">附近景点</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">社会公益</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">通信缴费</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">生活缴费</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">电影票</span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="icon"></span>
            <span class="text">全部应用</span>
          </a>
        </li>
      </ul>
    </div>
    <comp-banner>
      <template v-slot:fimg>
        <img src="../assets/teach.png" alt="" />
      </template>
      <template v-slot:simg>
        <img src="../assets/test.png" alt="" />
      </template>
      <template v-slot:timg>
        <img src="../assets/travail.png" alt="" />
      </template>
    </comp-banner>
    <comp-title>热门活动</comp-title>
    <div class="rmhd">
      <ul>
        <li>
          <a href="javascript:;">
            <span class="left">
              <h4>现金红包</h4>
              <p>10万用户来瓜分</p>
            </span>
            <span class="right">
              <img src="../assets/hongbao.png" alt="" />
            </span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="left">
              <h4>邀请好友</h4>
              <p>获取支付优惠券</p>
            </span>
            <span class="right">
              <img src="../assets/yaoqing.png" alt=""
            /></span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="left">
              <h4>金融保险</h4>
              <p>保障你的财富安全</p>
            </span>
            <span class="right">
              <img src="../assets/jinrong.png" alt=""
            /></span>
          </a>
        </li>
        <li>
          <a href="javascript:;">
            <span class="left">
              <h4>热门基金</h4>
              <p>带你赚不停</p>
            </span>
            <span class="right"> <img src="../assets/jijin.png" alt="" /></span>
          </a>
        </li>
      </ul>
    </div>
    <comp-title>周边生活</comp-title>
    <div class="zbsh">
      <ul>
        <li v-for="item in arrzbsh" :key="item.id">
          <a href="javascript:;">
            <span class="left">
              <img :src="item.img" alt="" />
            </span>
            <span class="right">
              <h4>{{ item.name }}</h4>
              <div class="local">
                <span>{{ item.local }} </span><span> {{ item.distance }}</span>
              </div>
            </span>
          </a>
        </li>
      </ul>
    </div>
    <comp-nomore></comp-nomore>
  </div>
</template>

<script>
import compHeader from "@/components/comp-header.vue";
import compTitle from "@/components/comp-title.vue";
import compBanner from "@/components/comp-banner.vue";
import compNomore from "@/components/comp-nomore.vue";
export default {
  name: "Home",
  components: {
    compHeader: compHeader,
    compTitle: compTitle,
    compBanner: compBanner,
    compNomore:compNomore
  },
  data() {
    return {
      arrzbsh: [],
      scrollTop1:0
    };
  },
  methods: {
    getData() {
      let pro = axios.get("/zbsh.jsonp");
      pro.then((response) => {
        if (response.data.code == 200) {
          let res = response.data.result;
          let arr = [];
          res.forEach((item) => {
            let obj = {};
            obj.img = require("../assets/" + item.picUrl);
            obj.id = item.id;
            obj.name = item.name;
            obj.local = item.local;
            obj.distance = item.distance;
            arr.push(obj);
          });
          this.arrzbsh = arr;
        }
      });
    },
  },
  mounted() {
    this.getData();
  },
  beforeRouteLeave(to, from, next) {
    this.scrollTop1 = document.documentElement.scrollTop || document.body.scrollTop;
    next();
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      window.scrollTo(0,vm.scrollTop1);
    });
  },
};
</script>

<style lang="scss" scoped>
.header {
  width: 100%;
  height: 260px;
  background: url(../assets/online.png) no-repeat;
  background-size: (960px * (4/10)) (591px * (4/10));
}
.box {
  height: 62px;
}
.pay-box {
  width: 355px;
  height: 122px;
  box-shadow: 0 0 5px #ccc;
  margin: 0 auto;
  position: relative;
  top: -60px;
  background-color: #fff;
  padding: 0 21px;
  box-sizing: border-box;
  .top {
    width: 100%;
    height: 85px;
    ul {
      width: 100%;
      height: 85px;
      display: flex;
      justify-content: space-around;
      align-items: center;
      li {
        flex-basis: 25%;
        flex-flow: 1;
        flex-shrink: 0;
        text-align: center;
        a {
          .icon {
            display: block;
            margin-left: 25px;
            width: 50px * (5/10);
            height: 50px * (5/10);
            background: url(../assets/sprite1.png) no-repeat;
            background-size: (623px * (5/10)) (1016px * (5/10));
          }
          .text {
            display: block;
            margin-top: 10px;
            font-size: 12px;
          }
        }
      }
      li:nth-child(1) .icon {
        background-position: (-80px * (5/10)) (-194px * (5/10));
      }
      li:nth-child(2) .icon {
        background-position: (-215px * (5/10)) (-194px * (5/10));
      }
      li:nth-child(3) .icon {
        background-position: (-355px * (5/10)) (-194px * (5/10));
      }
      li:nth-child(4) .icon {
        background-position: (-485px * (5/10)) (-194px * (5/10));
      }
    }
  }
  .bottom {
    width: 100%;
    height: 35px;
    border-top: 2px solid #ccc;
    ul {
      width: 100%;
      display: flex;
      justify-content: space-around;
      align-items: center;
      li {
        flex-basis: 25%;
        flex-flow: 1;
        flex-shrink: 0;
        text-align: center;
        .text {
          display: block;
          margin-top: 10px;
          font-size: 12px;
        }
      }
    }
  }
}
.types {
  width: 355px;
  height: 180px;
  padding: 0 21px;
  box-sizing: border-box;
  margin: 10px auto;
  ul {
    width: 100%;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    li {
      margin-top: 15px;
      flex-basis: 20%;
      flex-flow: 1;
      flex-shrink: 0;
      text-align: center;
      a {
        .icon {
          display: block;
          margin-left: 10px;
          width: 90px * (5/10);
          height: 90px * (5/10);
          background: url(../assets/sprite1.png) no-repeat;
          background-size: (623px * (5/10)) (1016px * (5/10));
        }
        .text {
          display: block;
          margin-top: 10px;
          font-size: 12px;
        }
      }
    }
    li:nth-child(1) .icon {
      background-position: (-65px * (5/10)) (-315px * (5/10));
    }
    li:nth-child(2) .icon {
      background-position: (-200px * (5/10)) (-315px * (5/10));
    }
    li:nth-child(3) .icon {
      background-position: (-340px * (5/10)) (-315px * (5/10));
    }
    li:nth-child(4) .icon {
      background-position: (-470px * (5/10)) (-315px * (5/10));
    }
    li:nth-child(5) .icon {
      background-position: (-65px * (5/10)) (-450px * (5/10));
    }
    li:nth-child(6) .icon {
      background-position: (-200px * (5/10)) (-450px * (5/10));
    }
    li:nth-child(7) .icon {
      background-position: (-340px * (5/10)) (-450px * (5/10));
    }
    li:nth-child(8) .icon {
      background-position: (-470px * (5/10)) (-450px * (5/10));
    }
    li:nth-child(9) .icon {
      background-position: (-65px * (5/10)) (-590px * (5/10));
    }
    li:nth-child(10) .icon {
      background-position: (-200px * (5/10)) (-590px * (5/10));
    }
  }
}

.rmhd {
  width: 355px;
  height: 180px;
  box-sizing: border-box;
  margin: 0 auto;
  ul {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    li {
      width: 168px;
      flex-basis: 168px;
      flex-shrink: 0;
      height: 80px;
      background-color: #ececec;
      border-radius: 5px;
      a {
        display: flex;
        width: 100%;
        height: 100%;
        .left {
          display: block;
          width: 60%;
          height: 100%;
          margin-left: 10px;
          h4 {
            font-size: 14px;
            padding-top: 20px;
          }
          p {
            margin-top: 8px;
            font-size: 12px;
            color: #999;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
        .right {
          display: block;
          width: 40%;
          height: 100%;
          line-height: 80px;
          img {
            width: 60px;
          }
        }
      }
    }
    li:nth-child(n + 3) {
      margin-top: 10px;
    }
  }
}
.zbsh {
  width: 345px;
  margin: 0 auto;
  ul {
    width: 345px;
    li {
      width: 345px;
      height: 105px;
      margin-top: 13px;
      box-shadow: 0 0 5px #ccc;
      border-radius: 5px;
      a {
        display: flex;
        .left {
          display: block;
          line-height: 105px;
          margin-left: 25px;
          img {
            width: 77px;
          }
        }
        .right {
          margin-left: 30px;
          display: block;
          font-size: 0;
          h4 {
            margin-top: 30px;
            font-size: 15px;
          }
          .local {
            margin-top: 10px;
            span {
              margin-top: 10px;
              font-size: 12px;
            }
          }
        }
      }
    }
  }
}

</style>